package com.tank.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.tank.bean.item.Item;
import com.tank.bean.item.Product;
import com.tank.bean.item.Talk;
import com.tank.service.HomeService;
import com.tank.util.Pager;
import com.tank.util.TankUtil;

@Controller("homeAction")
@Scope("prototype")
public class HomeAction extends ActionSupport {

	// User user;
	@Autowired
	@Qualifier("homeService")
	HomeService homeService;

	Item item;
	Product product;
	Talk talk;

	Pager pager;
	

	public HomeService getHomeService() {
		return homeService;
	}

	public void setHomeService(HomeService homeService) {
		this.homeService = homeService;
	}

	public Item getItem() {
		return item;
	}

	public void setItem(Item item) {
		this.item = item;
	}

	public Pager getPager() {
		return pager;
	}

	public void setPager(Pager pager) {
		this.pager = pager;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public Talk getTalk() {
		return talk;
	}

	public void setTalk(Talk talk) {
		this.talk = talk;
	}

	public String home() throws Exception {
		if (!TankUtil.isLogin()) {
			return LOGIN;
		}
		
		System.out.println("===homepager=");
		pager = homeService.listItem(item);
		System.out.println("list item ="+pager.data.size());
		System.out.println("===//homepager=");
		return SUCCESS;
	}

	

}
